// boolean
let isDone: boolean = false;
// let createdByNewBoolean: boolean = new Boolean(1);
let createdByNewBoolean1: boolean =  Boolean(1);
console.log(createdByNewBoolean1)

// number
let decLiteral: number = 5;
//16进制
let hexLiteral: number = 0x000d;
//2进制
let binaryLiteral: number = 0b1010;
//8进制
let octalLiteral: number = 0o744;
let notANumber: number = NaN;
let infinityNumber: number = Infinity;

// 字符串
let myName: string = 'Tom';
let myAge: number = 25;

// 模板字符串
let sentence: string = `hello, my name is ${myName}.
I'll be ${myAge + 1} years old next month`

// 空值
function alertName(): void {
    alert('My name is Tom');
}
let unsable: void = undefined;

// Null 和 Undefined
let u: undefined = undefined;
let n: null = null;

// 任意类型
let myFavoriteNumber: any = 'seven';
myFavoriteNumber = 7;
let anyThing: any = 'hello';
// 在任意值上访问任何属性都是允许的,ts不会报错,但是运行到js 如果没有的话就会报错
// console.log(anyThing.myName);
// console.log(anyThing.myName.firstName);
// anyThing.setName('Jerry');
// anyThing.setName('Jerry').sayHello();
// anyThing.myName.setFirstName('Cat');

// 未声明类型的变量§
// 变量如果在声明的时候，未指定其类型，那么它会被识别为任意值类型：
let something;//let something: any;
something = 'seven';
something = 7;

//类型推论
//如果没有明确的指定类型，那么 TypeScript 会依照类型推论（Type Inference）的规则推断出一个类型。
let aaNumber = 9;
aaNumber = 'nine';
//如果定义的时候没有赋值，不管之后有没有赋值，都会被推断成 any 类型而完全不被类型检查：
let aaAny;
aaAny = 2;
aaAny = "xc2";
aaAny = false;